<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><s:text name="context.title"/></title>
<%@ include file="/common/meta.jsp"%>
<link href="${ctx}/js/uploadify/uploadify.css" type="text/css" rel="stylesheet"/>
<script type="text/javascript" src="${ctx}/js/uploadify/jquery-ui.min.js"></script>
<script type="text/javascript" src="${ctx}/js/uploadify/swfobject.js"></script>
<script type="text/javascript" src="${ctx}/js/uploadify/jquery.uploadify.min.js"></script>
<link href="${ctx}/js/uploadify/uploadify.css" type="text/css" rel="stylesheet"/>
  <link rel="stylesheet" href="${ctx}/js/cluetip/jquery.cluetip.css" type="text/css" />
  <script src="${ctx}/js/cluetip/jquery.cluetip.min.js" type="text/javascript"></script>
<script type="text/javascript" language="javascript">
        $(function() {
    		$("#up").uploadify({
    			'height'        : 30,
    			'swf'           : '${ctx}/js/uploadify/uploadify.swf',
    			'uploader'      : '${ctx}/imp/teacher-data!upload.action',
    			'multi'         : false,
    			'auto'          : true,
    			'fileTypeExts'  : '*.xls',
    			'fileTypeDesc'  : 'EXCEL 97-2003',
    			'fileObjName'   : 'uploadFile',
    			'fileSizeLimit' : '0',
    			'removeCompleted': false,
    			'buttonText'     : '选Excel并上传',
    			'uploadLimit'	: '5',
    		   	  'onUploadComplete'	  : function(file){
    		   	   	  document.URL = "teacher-data!input.action";
    		   	   	  }
    		});

        });

        $(document).ready(function(){
			$("#more").click(function(){
				var inxx = $("#contentTable1").find("tr").size() - 1;
				$.post("teacher-data!getDown","",function(data){
					var strHtml = "";
					$.each(data,function(inx,obj){
						strHtml += "<tr>";
						strHtml += "<td>" +(++inxx)+ "&nbsp;</td>";
						strHtml += "<td>" +obj.college+ "&nbsp;</td>";
						strHtml += "<td>" +obj.name+ "&nbsp;</td>";
						strHtml += "<td>" +obj.no+ "&nbsp;</td>";
						strHtml += "<td>" +obj.titile+ "&nbsp;</td>";
						strHtml += "<td>" +obj.workDate+ "&nbsp;</td>";
						strHtml += "<td>" +obj.phone+ "&nbsp;</td>";
						strHtml += "<td>" +obj.email+ "&nbsp;</td>";
						strHtml += "<td><div title="+obj.memo+">" +obj.memo.substr(0,10)+ "...</div>&nbsp;</td>";
						
						strHtml += "</tr>";
						});
					$("#contentTable1").append(strHtml);
				},"json");
            });

			 $("#submit").click(function(){
	            	if(!confirm('此过程需要比较长的时间。请耐心等待并且不要刷新本页面。。\n\n确定提交?')){
						return false;
	            	}
	            	$(this).val("导入中.........");
	               	$(this).attr("disabled","disabled");
					$.post("teacher-data!submit.action",null,function(data){
						if(data != ''){
							alert("操作成功");
						}else{
							alert(data);
						}					
						document.URL = "teacher-data.action";
						});
	                });
        });
 </script>
</head>
<body>
<form action="teacher-data" method="post">
<br/>
<p align="center"><s:actionmessage theme="mytheme" cssClass="actionMessage"/></p>
<h1 class="title01"><img src="${ctx}/images/02_15.gif" width="45" height="42" class="fl"/>导入教师数据</h1>
<fieldset class="fs_ys" style="width: 600px">
<legend>从Excel导入</legend>
<input type="file" name="uploadFile" id="up"/>
</fieldset>
<s:if test="excelErrors != null && excelErrors.size() != 0">
<table id="contentTable1" class="table_ys tableColor table_ys_input">
	<tr>
		<th>序号</th>
		<th>所在行号</th>
		<th>所在列名</th>
		<th>错误信息</th>
	</tr>
	<s:iterator var="v" value="excelErrors" status="st">
		<tr>
			<td align="center">${st.index + 1 }&nbsp;</td>
			<td align="center">${row}&nbsp;</td>
			<td align="center">${columnName }&nbsp;</td>
			<td align="left">${content }&nbsp;</td>
		</tr>
	</s:iterator>
</table>
</s:if>
<s:if test="tempList != null && tempList.size() != 0">
<table id="contentTable1" class="table_ys tableColor table_ys_input">
	<tr>
		<th>序号</th>
		<th>学院</th>
		<th>教师姓名</th>
		<th>工号</th>
		<th>职称</th>
		<th>工作时间</th>
		<th>电话</th>
		<th>E-mail</th>
		<th>备注</th>
	</tr>
	<s:iterator var="v" value="tempList" status="st">
	<!-- 考虑到可能导入上千条数据。这时如果全部分显示出来IE可能会受不了，所以，默认只显示50条 -->
	<s:if test="#st.index < SHOUYU_COUNT">
	<tr>
		<td>${st.index +1}&nbsp;</td>
		<td>${college }&nbsp;</td>
		<td>${name }&nbsp;</td>
		<td>${no }&nbsp;</td>
		<td>${titile }&nbsp;</td>
		<td>${workDate }&nbsp;</td>
		<td>${telephone }&nbsp;</td>
		<td>${email }&nbsp;</td>
		<td><div title='${memo }'><s:property value="#v.memo.substring(0,10)"/></div>&nbsp;</td>
	</tr>
	</s:if>
	</s:iterator>
</table>
	<s:if test="tempList.size() > SHOUYU_COUNT">
		<center><a href="javascript:;" id="more">更多</a></center>
	</s:if>
	
	<center><input type="button" value="提交"  class="input_ys1" id="submit" name="method:submit" /></center>
</s:if>
</form>
</body>

</html>